package controllers

import (
    "github.com/gin-gonic/gin"
    "hitme/go-api/logic/form"
    "hitme/go-api/logic/services"
    "hitme/go-api/modules/response"
    "hitme/go-api/modules/utils"
)

type wechatController struct {

}

var WechatController wechatController

// Login 微信登录
func (w *wechatController) Login (c *gin.Context)  {
    // 获取参数并校验字段
    req := form.WechatLoginReqForm{}
    if err := c.ShouldBind(&req); err != nil {
        utils.HandleValidatorError(c, err)
        return
    }

    res, err := services.WechatService.Login(c, req)

    if err != nil {
        response.Err(c, 400, 400, err.Error())
    } else {
        response.Success(c, 200, res)
    }
}